using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour {
	public GameObject candyPrefab;
	Vector3		inputStart = new Vector3();	// 入力開始点

	// Use this for initialization
	void Start () {
	}
	
	// Update is called once per frame
	void Update () {

		if(Input.GetMouseButtonUp(0)) {
			Vector3 diff = new Vector3(
			    Input.mousePosition.x - inputStart.x,
			    0.0f,
			    Input.mousePosition.y - inputStart.y);
			if(diff.x < 0) return;

			diff.Normalize();
			GameObject candy = (GameObject)Instantiate(candyPrefab);
			candy.GetComponent<ThrowCandy>().Move = diff * 0.15f;
		}

		if(Input.GetMouseButtonDown(0)) {
			inputStart = Input.mousePosition;
		}
	}
}
